/**
 * 
 */
package com.jysz.struts2.views.jsp.ui;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts2.components.Component;
import org.apache.struts2.views.jsp.ui.TextFieldTag;

import com.jysz.struts2.components.AutoCompleter;
import com.opensymphony.xwork2.util.ValueStack;

/**
 * @author <a href="mailto:javaengine@outlook.com">Kaca Rich</a>
 *
 */
public class AutoCompleterTag extends TextFieldTag{

	private String classType;
	private String dataUrl;
	private String displayTemplate;
	private String displayFields;//逗号分隔
    private String fieldMapping;//{"nameField":"name","realNameField":"realName"}
    private String callBackFun;//回调函数
    private String filterSql;//过滤的sql条件
    private String noSelectedClear; // 未选择清空数据。。默认为false;
    
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
    public Component getBean(ValueStack stack, HttpServletRequest req, HttpServletResponse res) {
        return new AutoCompleter(stack, req, res);
    }
    
    protected void populateParams() {
        super.populateParams();

        AutoCompleter autoCompleter = ((AutoCompleter) component);
        
        autoCompleter.setClassType(classType);
        autoCompleter.setDataUrl(dataUrl);
        autoCompleter.setDisplayFields(displayFields);
        autoCompleter.setFieldMapping(fieldMapping);
        autoCompleter.setCallBackFun(callBackFun);
        autoCompleter.setFilterSql(filterSql);
        autoCompleter.setNoSelectedClear(noSelectedClear);
        
    }

    
	public String getNoSelectedClear() {
		return noSelectedClear;
	}

	public void setNoSelectedClear(String noSelectedClear) {
		this.noSelectedClear = noSelectedClear;
	}

	public String getClassType() {
		return classType;
	}

	public void setClassType(String classType) {
		this.classType = classType;
	}

	public String getDataUrl() {
		return dataUrl;
	}

	public void setDataUrl(String dataUrl) {
		this.dataUrl = dataUrl;
	}

	public String getDisplayTemplate() {
		return displayTemplate;
	}

	public void setDisplayTemplate(String displayTemplate) {
		this.displayTemplate = displayTemplate;
	}

	public String getDisplayFields() {
		return displayFields;
	}

	public void setDisplayFields(String displayFields) {
		this.displayFields = displayFields;
	}

	public String getFieldMapping() {
		return fieldMapping;
	}

	public void setFieldMapping(String fieldMapping) {
		this.fieldMapping = fieldMapping;
	}

	public String getCallBackFun() {
		return callBackFun;
	}

	public void setCallBackFun(String callBackFun) {
		this.callBackFun = callBackFun;
	}

	public String getFilterSql() {
		return filterSql;
	}

	public void setFilterSql(String filterSql) {
		this.filterSql = filterSql;
	}
	
	
}
